const crypto = require('crypto'); // 使用 Node.js 的 crypto 模块
const d = "fanyideskweb";
const u = "webfanyi";
const p = "client,mysticTime,product";
const m = "1.0.0";
const h = "web";
const g = "fanyi.web";
const b = 1;
const f = 1;
const v = 1;
const A = "wifi";
const y = 0;
function _(e) {
    return crypto.createHash("md5").update(e.toString()).digest("hex");
}
function S(mysticTime, key) {
    const str = `client=${d}&mysticTime=${mysticTime}&product=${u}&key=${key}`;
    return _(str);
}
function get_time_sign() {
    const mysticTime = Date.now(); // 当前时间戳
    const key = 'Vy4EQ1uwPkUoqvcP1nIu6WiAjxFeA3Y3'; // 模拟密钥
    const sign = S(mysticTime, key); // 生成签名
    return [mysticTime, sign];
}

function translate(text) {
    const key = Buffer.from([

           8, 20, 157, 167, 60, 89, 206, 98,
        85, 91, 1, 233, 47, 52, 232, 56
    ]);

    const iv = Buffer.from([
         210, 187, 27, 253, 232, 59, 56, 195,
        68, 54, 99, 87, 183, 156, 174, 28

    ]);
    const decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);

        // 分步解密处理
    let decrypted = decipher.update(text, 'base64', 'utf-8');
    decrypted += decipher.final('utf-8');
        return JSON.parse(decrypted);
}
function r(text){
    return translate(text)['translateResult'][0][0]['tgt']
}
